#include "UIComponent.h"

UIComponent::UIComponent(){
    _uid = _uicount++;
    if(!oftFont){
        oftFont = oslLoadIntraFontFile("flash0:/font/gb3s1518.bwfon", INTRAFONT_STRING_UTF8);
        oslIntraFontSetStyle(oftFont, 0.8f, WHITE, 0, 0);

        latinFont = oslLoadFontFile("flash0:/font/ltn0.pgf");
        oslIntraFontSetStyle(latinFont, 0.8f, WHITE, 0, 0);

        jpFont = oslLoadIntraFontFile("flash0:/font/jpn0.pgf", INTRAFONT_STRING_SJIS);
        oslIntraFontSetStyle(jpFont, 0.8f, WHITE, 0, 0);
    }

    latinfont = latinFont;
    font = oftFont;
    jpfont = jpFont;

    state = 0;
    downloadable = false;
    runnable = false;
    percent = 0;
}

UIComponent::~UIComponent(){
    //delete this;
}

void UIComponent::draw(){
    if(state == 0){
        oslDrawRect(_x, _y, _x+_width, _y+_height, RGB(255,255,0));
    }else if(state == 1){
        oslDrawRect(_x, _y, _x+_width, _y+_height, RGB(0,255,255));
    }else if(state == 2){
        oslDrawRect(_x, _y, _x+_width, _y+_height, RGB(255,0,255));
    }
}

void UIComponent::onselect(){
    state = 2;
}

void UIComponent::onblur(){
    state = 0;
}

void UIComponent::onhover(){
    state = 1;
}
